<?php
namespace app\fun1219\model;

use think\Model;
use app\fun1219\model\Article;
use app\fun1219\model\Leacots;

class Index extends Model
{

    protected $art_moedel;
    protected $lea_moedel;

    public function __construct()
    {
        $this->art_moedel = new Article();
        $this->lea_moedel = new Leacots();
    }

    public function getList()
    {
        $map = [];

        $data = $this->art_moedel->where($map)
            ->field('id,title,pubtime,summary,sort,top,clicks')
            ->order('sort', 'desc')
            ->order('clicks', 'desc')
            ->paginate();

        return $data;
    }

    public function getContent($id)
    {
        $data = $this->art_moedel->where('status', 1)->find($id);

        return $data;
    }

    public function saveLeacots($data)
    {
        $res = $this->lea_moedel->save([
            'content'=>$data['content'],
            'link'=>$data['link']
        ]);

        if ($res===false) {
            return false;
        } else {
            return true;
        }
    }
}
